<?php echo form_open(uri_string(), 'class="crud" id="contact-info-form"'); ?>
<?php echo form_hidden('escort_id', $escort->getId()) ?>
<?php 
	$geoArray = explode('#', $escort->getGeolocation());
	$lat = count($geoArray)==2 ? $geoArray[0] :'0';
	$lng = count($geoArray)==2 ? $geoArray[1] :'0';
?>
<fieldset>
	<ul id="personal-content" class="ui-sortable form_inputs">
		<li class="" id="header">
			<label for="header">&nbsp;</label>
			<div class="input type-text three-column">
				<div class="three-column-first">
					&nbsp;
				</div>
				<div class="three-column-second">
				<?php echo lang('escort_be_escort_public_label')?>
				</div>
				<div class="three-column-third">
				<?php echo lang('escort_be_escort_locked_label')?>
				</div>
			</div>
		</li>
		<li class="" id="personal_visit">
			<label for="site_name"><?php echo lang('escort_be_escort_contact_display_name_label')?></label>
			<div class="input type-text three-column">
				<div class="three-column-first">
				<input type="text" name="contact_info_name" id="contact_info_name" value="<?php echo $escort->getEscortName();?>" maxlength="15" class="text-box3">
				</div>
				<div class="three-column-second">
				&nbsp;
				</div>
				<div class="three-column-third">
				&nbsp;
				</div>
			</div>
		</li>
		<li class="" id="personal_visit">
			<label for="site_name"><?php echo lang('escort_be_escort_contact_phone_label')?></label>
			<div class="input type-text three-column">
				<div class="three-column-first">
				<input type="text" name="contact_info_phone" id="contact_info_phone" value="<?php echo $escort->getEscortPhone();?>" maxlength="15" class="text-box3">
				</div>
				<div class="three-column-second">
				<?php echo form_checkbox('public_phone', 1, $escort->getPublicPhone(), 'class="escort-checkbox"')?>
				</div>
				<div class="three-column-third">
				<?php echo form_checkbox('locked_phone',1,$lockedEscort->getLockedPhone(), 'class="escort-checkbox"')?>
				</div>
			</div>
		</li>
		<li class="" id="personal_position">
			<label for="site_name"><?php echo lang('escort_be_escort_contact_email_label')?></label>
			<div class="input type-text three-column">
				<div class="three-column-first">
				<input type="text" name="contact_info_email" id="contact_info_email" value="<?php echo $escort->getEscortEmail();?>" maxlength="45" class="text-box3">
				</div>
				<div class="three-column-second">
				<?php echo form_checkbox('public_email', 1, $escort->getPublicEmail(), 'class="escort-checkbox"')?>
				</div>
				<div class="three-column-third">
				<?php echo form_checkbox('locked_email',1,$lockedEscort->getLockedEmail(), 'class="escort-checkbox"')?>
				</div>
			</div>	
		</li>
		<li class="" id="personal_contact_data">
			<label for="escort_birthday"><?php echo lang('escort_be_escort_contact_address_label')?></label>
			<div class="input type-text three-column">
				<div class="three-column-first">
				<input type="text" name="contact_info_address" id="contact_info_address" value="<?php echo $escort->getEscortAddress();?>" maxlength="255" class="text-box3">
				</div>
				<div class="three-column-second">
				<?php echo form_checkbox('public_address', 1, $escort->getPublicAddress(), 'class="escort-checkbox"')?>
				</div>
				<div class="three-column-third">
				<?php echo form_checkbox('locked_address',1,$lockedEscort->getLockedAddress(), 'class="escort-checkbox"')?>
				</div>
			</div>
		</li>
		<li class="" id="personal_current_services">
			<label for="escort_birthday"><?php echo lang('escort_be_escort_contact_geolocalization_label')?></label>
			<div class="input type-text three-column">
				<div class="three-column-first">
				<a href="javascript:void(0);" onclick="javascript:return getGeolocation();" ><?php echo lang('escort_be_escort_contact_geolocalization_now_label');?></a>
				</div>
				<div class="three-column-second">
				<?php echo form_checkbox('public_geolocation', 1, $escort->getPublicGeolocation(), 'class="escort-checkbox"')?>
				</div>
				<div class="three-column-third">
				<?php echo form_checkbox('locked_geolocation',1,$lockedEscort->getLockedGeolocation(), 'class="escort-checkbox"')?>
				</div>
			</div>
		</li>
		<li class="" id="personal_last_payment">
			<label for="escort_birthday"><?php echo lang('escort_be_escort_contact_show_map_on_profile_label')?></label>
			<div class="input type-text">
				<div id="google_map_add_form" style="width:350px;height:350px;"></div> 
			</div>
		</li>
		<li class="" id="personal_current_services">
			<label for="escort_birthday"><?php echo lang('escort_be_escort_contact_show_address_on_map_label')?></label>
			<div class="input type-text three-column">
				<div class="three-column-first">
				&nbsp;
				</div>
				<div class="three-column-second">
				<?php echo form_checkbox('contact_info_show_address_on_map', 1, $escort->getShowAddressOnMap(), 'class="escort-checkbox"')?>
				</div>
				<div class="three-column-third">
				<?php echo form_checkbox('locked_map',1,$lockedEscort->getLockedMap(), 'class="escort-checkbox"')?>
				</div>
			</div>
		</li>
		<li class="" id="personal_current_services">
			<label for="escort_birthday"><?php echo lang('escort_be_escort_contact_receive_messages_label')?></label>
			<div class="input type-text three-column">
				<div class="three-column-first">
				<?php echo form_checkbox('contact_info_receive_message', 1, $escort->getReceiveMessage(), 'class="escort-checkbox"')?>
				</div>
				<div class="three-column-second">
				&nbsp;
				</div>
				<div class="three-column-third">
				&nbsp;
				</div>
			</div>
		</li>
	</ul>
	<?php echo form_button(array('id'=>'save-contact-info', 'onClick'=>'saveContactInfo()','name'=>'add', 'class'=>'btn blue', 'value'=>lang('escort_be_escort_contact_save_label'), 'content'=>lang('escort_be_escort_contact_save_label')))?>
</fieldset>
<?php echo form_close()?>
<script type="text/javascript">
jQuery(document).ready(function() {	
	var options = { 
		beforeSubmit:  validateB4SubmitContactInfo,  
		success:       processAfterRespondingContactInfo   
	};	
	//jQuery('#submit_contact_info').ajaxForm(options); 
	//initialize(<?php echo $lat ;?>,<?php echo $lng ;?>);
});	
function validateB4SubmitContactInfo(formData, jqForm, options){
	jQuery('#contact_info_loader_image').show();
	return true;
}

function processAfterRespondingContactInfo(responseText, statusText, xhr, $form) {
	jQuery('#contact_info_loader_image').hide();	
	if(responseText == 'ok'){
		queryurl(BASE_URI+'escort_user/profile/contact_info');
		reload();
	}else{
		var arr_res = responseText.split('#');
		for(i in arr_res){
			var e = arr_res[i].split('|');
			$('#'+e[0]).html(e[1]);
		}
		//debug(responseText);
	}
}


function success(position) {
  var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
  var myOptions = {
    zoom: 14,
    center: latlng,
    mapTypeControl: true,
    navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("google_map_add_form"), myOptions);
 
  google.maps.event.addListener(map, 'click', function(event) {
    mapEditor(event.latLng);
  });
  marker = new google.maps.Marker({
	position: latlng,
	map: map
  });
   jQuery('#contact_lat').attr('value', position.coords.latitude ); 
   jQuery('#contact_lng').attr('value', position.coords.longitude ); 
}

function error(msg) {
	debug(msg);
}

function getGeolocation(){
	if (navigator.geolocation) {
	  navigator.geolocation.getCurrentPosition(success, error);
	} else {
	   debug('not supportted');
	}
}
</script>	